/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ExportSlaveDialog.java
 *
 * Created on 28 janv. 2009, 09:49:23
 */

package modbuspal.slave;

/**
 *
 * @author nnovic
 */
class ExportSlaveDialog
extends javax.swing.JDialog
{
    private boolean okPushed = false;

    /** Creates new form ExportSlaveDialog */
    public ExportSlaveDialog(java.awt.Frame parent)
    {
        super(parent, true);
        initComponents();
    }

    boolean isOK()
    {
        return okPushed;
    }

    boolean exportBindings()
    {
        return (bindingsCheckBox.isEnabled() && bindingsCheckBox.isSelected());
    }

    boolean exportAutomations()
    {
        return (automationsCheckBox.isEnabled() && automationsCheckBox.isSelected());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jLabel1 = new javax.swing.JLabel();
        bindingsCheckBox = new javax.swing.JCheckBox();
        automationsCheckBox = new javax.swing.JCheckBox();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Export slave");
        getContentPane().setLayout(new java.awt.GridBagLayout());

        jLabel1.setText("Choose your export options:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        getContentPane().add(jLabel1, gridBagConstraints);

        bindingsCheckBox.setText("Export with bindings");
        bindingsCheckBox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bindingsCheckBoxActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        getContentPane().add(bindingsCheckBox, gridBagConstraints);

        automationsCheckBox.setText("Export with automations");
        automationsCheckBox.setEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        getContentPane().add(automationsCheckBox, gridBagConstraints);

        okButton.setText("OK");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        getContentPane().add(okButton, gridBagConstraints);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void bindingsCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bindingsCheckBoxActionPerformed
        automationsCheckBox.setEnabled( bindingsCheckBox.isSelected() );
    }//GEN-LAST:event_bindingsCheckBoxActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        okPushed = true;
        setVisible(false);
    }//GEN-LAST:event_okButtonActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox automationsCheckBox;
    private javax.swing.JCheckBox bindingsCheckBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JButton okButton;
    // End of variables declaration//GEN-END:variables

}
